<%@ page import="com.alibaba.fastjson.JSON" %>
<%@ page import="top.sehnsucht.vo.Result" %>
<%@ page import="org.apache.log4j.Logger" %>
<%@ page import="top.sehnsucht.dao.UserPhotoDao" %>
<%@ page import="top.sehnsucht.dao.impl.UserPhotoDaoImpl" %>
<%@ page import="top.sehnsucht.service.UserPhotoService" %>
<%@ page import="top.sehnsucht.service.impl.UserPhotoServiceImpl" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Logger logger = Logger.getLogger(this.getClass());

    response.setHeader("Content-Type", "application/json;charset=UTF-8");//注意加上这一句

    logger.debug("现在路径是: " + request.getRequestURL());

    Result result = new Result();
    result.setCode(0);
    result.setCount(1L);

    //清空session
    request.getSession().getServletContext().setAttribute("allPicUrls", "");
    request.getSession().getServletContext().setAttribute("allFilename", "");

    UserPhotoDao userPhotoDao = new UserPhotoDaoImpl();
    UserPhotoService userPhotoService = new UserPhotoServiceImpl(userPhotoDao);

    String name = request.getParameter("name");
    String startDate = (request.getParameter("startDate"));
    String endDate = request.getParameter("endDate");

    System.out.println(startDate);
    System.out.println(request.getParameter("startDate"));
    System.out.println(endDate);

    if (startDate != null && startDate.equals("")) {
        startDate = null;
    }
    if (endDate != null && endDate.equals("")) {
        endDate = null;
    }

    System.out.println(userPhotoService.getSomeUser(name, startDate, endDate));

    String json = JSON.toJSONString(userPhotoService.getSomeUser(name, startDate, endDate));

    System.out.println(json);

//    String json = JSON.toJSONString(userPhotoService.getAllUser());

    out.println("{\"code\":" + result.getCode() + ",\"msg\":\"\",\"count\":" + result.getCount() + ",\"data\":" + json + "}");
%>

